

function zoomPic(ele,opt) {
    var ele = $(ele);
    var prev = ele.find('.prev');
    var next = ele.find('.next');
    var elesBox = ele.find('ul');
    var len = opt[0].length;
    var eles = elesBox.find('li');
    var elesLen = eles.length;
    var showEleLen = Math.floor(len/2);
    var num = 0;
    var timer = null;
    var clickTimer = null;
    var isTimer = false;
    var spansStr = '';
    for (var n=1;n<=elesLen;n++){
        spansStr+='<span>'+n+'</span>';
    }
    ele.find('.arrowTips').html(spansStr);
    ele.find('.arrowTips span').eq(num).addClass('now').siblings('span').removeClass('now');


    for (var i=0;i<=showEleLen;i++){
        eles.eq(i).css(opt[1][i]).animate(opt[0][i],300);
    }
    for (j=showEleLen;j>0;j--){
        eles.eq(elesLen-j).css(opt[1][len-j]).animate(opt[0][len-j],300);
    }
    timer = setInterval(function(){
        if(isTimer){
            return false;
        }
        num++;
        if(num>=elesLen){
            num=0
        }
        ani(num);

    },3000);
    eles.click(function(){
        num = $(this).index();
        isTimer = true;
        clearTimeout(clickTimer);
        ani(num);
        clickTimer = setTimeout(function(){
            isTimer = false;
        },5000)
    });
    prev.click(function(){
        num--;
        if(num<0){
            num = elesLen-1;
        }
        isTimer = true;
        clearTimeout(clickTimer);
        ani(num);
        clickTimer = setTimeout(function(){
            isTimer = false;
        },5000)
    });
    next.click(function(){
        num++;
        if(num>=elesLen){
            num=0
        }
        isTimer = true;
        clearTimeout(clickTimer);
        ani(num);
        clickTimer = setTimeout(function(){
            isTimer = false;
        },5000)
    });
    ele.on('click','.arrowTips span',function () {
        num = $(this).index();
        isTimer = true;
        clearTimeout(clickTimer);
        ani(num);
        clickTimer = setTimeout(function(){
            isTimer = false;
        },5000)
    })

    function ani(num) {
        for (x=0;x<elesLen;x++){
            eles.eq(x).css({'opacity':0});
        }
        for (var i=num;i<=showEleLen+num;i++){
            var idx = i;
            if(idx>=elesLen){
                idx = idx-elesLen
            }
            eles.eq(idx).css(opt[1][i-num]).animate(opt[0][i-num],300);

        }
        for (j=showEleLen;j>0;j--){
            var idx = num+j-showEleLen-1;
            if(idx<0){
                idx = idx+elesLen;
            }
            eles.eq(idx).css(opt[1][len-j]).animate(opt[0][len-j],300);
        }
        ele.find('.arrowTips span').eq(num).addClass('now').siblings('span').removeClass('now');

    }
}
